package com.oschina.wed.common.utils;

import java.lang.reflect.Field;
import java.util.Hashtable;

public class CommonUtils {

    public static Hashtable<String, Object> convert2HashTable(Object obj) {
        Hashtable<String, Object> table = new Hashtable<String, Object>();
        Field[] fields = obj.getClass().getDeclaredFields();
        for (Field field : fields) {
            field.setAccessible(true);
            try {
                if(field.get(obj) != null) {
                    table.put(field.getName(), field.get(obj));
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        return table;
    }
}
